package com.xyz.study;

import com.alibaba.fastjson.JSON;
import com.xyz.study.spring.event.TestSpringEventPublisher;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;

@SpringBootApplication
@EnableAsync
public class StudyApplication {

    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(StudyApplication.class, args);
        TestSpringEventPublisher testSpringEventPublisher = context.getBean(TestSpringEventPublisher.class);
        for (int i = 0; i < 10; i++){
            testSpringEventPublisher.publishEvent(String.valueOf(i), "xyz");
        }
        // 关闭Spring容器
        ((ConfigurableApplicationContext) context).close();
    }

}
